
#ifndef _PRINTING_C_
#define _PRINTING_C_

#include "printing.h"
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

void prints(double * array_first, int dim1, int dim2, char graph_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   "Print Array": Takes in address of first element of 2D array and prints out, labeled    |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<dim1; i++){
        for (int j=0; j<dim2; j++){
            printf("%f, ", array_first[i*dim1+j]);
        }
        printf("\n");
    }
    printf("\n\n");
}

void prints(double * array_first, int dim1, char graph_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   "Print Array": Takes in address of first element of 1D array and prints out, labeled    |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<dim1; i++){
        printf("%f, ", array_first[i]);
    }
    printf("\n\n");
}

void prints(vector<vector<double> > myvector, char graph_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   "Print Vector": Takes in address of 2D vector and prints out, labeled                   |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<myvector.size(); i++){
        for (int j=0; j<myvector[i].size(); j++){
            printf("%f, ", myvector[i][j]);
        }
        printf("\n");
    }
    printf("\n\n");
}

void prints(vector<double> myvector, char graph_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   "Print Vector": Takes in address of 1D vector and prints out, labeled                   |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<myvector.size(); i++){
        printf("%f, ", myvector[i]);
    }
    printf("\n\n");
}

void prints(vector<vector<int> > myvector, char graph_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   "Print Vector": Takes in address of 2D vector and prints out, labeled                   |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<myvector.size(); i++){
        for (int j=0; j<myvector[i].size(); j++){
            printf("%i, ", myvector[i][j]);
        }
        printf("\n");
    }
    printf("\n\n");
}

void prints(vector<int> myvector, char graph_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   "Print Vector": Takes in address of 1D vector and prints out, labeled                   |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<myvector.size(); i++){
        printf("%i, ", myvector[i]);
    }
    printf("\n\n");
}

void prints(vector<vector<string> > myvector, char graph_label[100]){
    /*---------------------------
#endif---------------------------------------------------------------*
    |   "Print Vector": Takes in address of 2D vector and prints out, labeled                   |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<myvector.size(); i++){
        for (int j=0; j<myvector[i].size(); j++){
            printf("%s, ", myvector[i][j].c_str());
        }
        printf("\n");
    }
    printf("\n\n");
}

void prints(vector<string> myvector, char graph_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   "Print Vector": Takes in address of 1D vector and prints out, labeled                   |
    *------------------------------------------------------------------------------------------*/

    printf("Showing %s:\n\n", graph_label);
    for (int i=0; i<myvector.size(); i++){
        printf("%s, ", myvector[i].c_str());
    }
    printf("\n\n");
}

void printcsv(vector<pair<double, double> > mypoints, char file_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   Takes in vector of pairs and formats as a csv file for opening in excel.                |
    *------------------------------------------------------------------------------------------*/

    FILE * csvFile;
    csvFile = fopen(file_label, "w");
    for (int i=0; i<mypoints.size(); i++){
        fprintf(csvFile, "%f, %f,\n", mypoints[i].first, mypoints[i].second);
    }
    fclose(csvFile);
}

void printcsv(vector<double> mypoints, char file_label[100]){
    /*------------------------------------------------------------------------------------------*
    |   Takes in vector of pairs and formats as a csv file for opening in excel.                |
    *------------------------------------------------------------------------------------------*/

    FILE * csvFile;
    csvFile = fopen(file_label, "w");
    for (int i=0; i<mypoints.size(); i++){
        fprintf(csvFile, "%f, \n", mypoints[i]);
    }
    fclose(csvFile);
}

void wait_for_key(){
    cout << endl << "Press ENTER to continue..." << endl;

    cin.clear();
    cin.ignore(cin.rdbuf()->in_avail());
    cin.get();
    return;
}

#endif
